<?php

/**
 *    管理员日志控制器
 *
 *    @author    Yanghj
 *    @date    2014.04.28
 */
class AdminlogApp extends BackendApp
{
    var $_adminlog_mod;

    function __construct()
    {
        $this->AdminlogApp();
    }

    function AdminlogApp()
    {
        parent::BackendApp();

        $this->_adminlog_mod = & m('adminlog');
    }

    /**
     *    管理员日志主页
     *
     *    @return    void
     */
    function index()
    {
        $conditions = $this->_get_query_conditions(array(array(
                'field' => 'user_name',       
                'equal' => 'LIKE',
                'name'  => 'search_name',
            ),array(
                'field' => 'log_time',
                'name'  => 'add_time_from',
                'equal' => '>=',
                'handler'=> 'gmstr2time',
            ),array(
                'field' => 'log_time',
                'name'  => 'add_time_to',
                'equal' => '<=',
                'handler'   => 'gmstr2time_end',
            ),
        ));
        
        //更新排序
        if (isset($_GET['sort']) && isset($_GET['order']))
        {
            $sort  = strtolower(trim($_GET['sort']));
            $order = strtolower(trim($_GET['order']));
            if (!in_array($order,array('asc','desc')))
            {
             $sort  = 'log_id';
             $order = 'desc';
            }
        }
        else
        {
            $sort  = 'log_id';
            $order = 'desc';
        }
        
        $page = $this->_get_page();
        $adminlog_info = $this->_adminlog_mod->find(array(
            'conditions'    => '1=1 ' . $conditions,
            'limit' => $page['limit'],
            'order' => "$sort $order",
            'count' => true,
        ));
        $page['item_count'] = $this->_adminlog_mod->getCount();
        $this->_format_page($page);
        $this->assign('filtered', $conditions? 1 : 0); //是否有查询条件
        $this->assign('page_info',$page);
        $this->assign('adminlog',$adminlog_info);
        //var_dump($page);
        //var_dump($adminlog_info);
        $this->import_resource(array('script' => 'inline_edit.js,jquery.ui/jquery.ui.js,jquery.ui/i18n/' . i18n_code() . '.js',
                                      'style'=> 'jquery.ui/themes/ui-lightness/jquery.ui.css'));
        $this->display('adminlog.index.html');
    }
    /**
     *    管理员日志删除
     *
     */

    function drop()
    {
        $ids = isset($_GET['id']) ? trim($_GET['id']) : '';
        if (!$ids)
        {
            $this->show_warning('no_adminlog_to_drop');

            return;
        }
        $ids=explode(',',$ids);
        $this->_adminlog_mod->drop($ids);
        if ($this->_adminlog_mod->has_error())    //删除
        {
            $this->show_warning($this->_adminlog_mod->get_error());

            return;
        }

        $this->show_message('drop_ok');
    }

}

?>